<template>
  <footer class="footer">
    <span class="todo-count">剩余<strong>{{ length }}</strong></span>
    <ul
      class="filters"
      @click="changeShow"
    >
      <li>
        <a
          :class="{selected: flag === 'all'}"
          href="javascript:;"
          @click="flag = 'all'"
        >全部</a>
      </li>
      <li>
        <a
          :class="{selected: flag === 'no'}"
          href="javascript:;"
          @click="flag = 'no'"
        >未完成</a>
      </li>
      <li>
        <a
          :class="{selected: flag === 'yes'}"
          href="javascript:;"
          @click="flag = 'yes'"
        >已完成</a>
      </li>
    </ul>
    <button
      class="clear-completed"
      @click="clearTask"
    >清除已完成</button>
  </footer>
</template>

<script>
export default {
  props: {
    length: Number
  },
  data() {
    return {
      // 标记
      flag: 'all'
    }
  },
  methods: {
    changeShow() {
      this.$emit('changeShow', this.flag)
    },
    // 自定义事件
    clearTask() {
      this.$emit('clearTask')
    }
  }
}
</script>